﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Core;
using SharedGenomics.Workbench.Core;
using SharedGenomics.Domain;

namespace SharedGenomics.Workbench.Services
{
    public class FileSchemaRepository : WCFClientHost, IFileSchemaRepository
    {
        public Maybe<IEnumerable<EntityInfo>> GetFileSchemaInfos()
        {
            return this.ExecuteProxyContract<DataService.IDataService, IEnumerable<EntityInfo>>(ds => ds.GetUserFileSchemaInfos()).Just();
        }

        public Maybe<FileSchema> GetSchemaById(int fileSchemaId)
        {
            return this.ExecuteProxyContract<DataService.IDataService, FileSchema>(ds => ds.GetSchema(fileSchemaId)).Just();
        }

        public void AddSchema(FileSchema schema)
        {
            schema.ThrowIfNull("schema");
            this.ExecuteProxyContract<DataService.IDataService>(ds => { ds.AddSchema(schema); });
        }
    }
}
